<!DOCTYPE html>
<!--suppress ThymeleafVariablesResolveInspection -->
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>天天生鲜-购物车</title>
	<div th:replace="header::common_resource"></div>
</head>
<body>
	<div th:replace="top::top"></div>

	<div class="total_count">全部商品<em>2</em>件</div>	
	<ul class="cart_list_th clearfix">
		<li class="col01">商品名称</li>
		<li class="col03">商品价格</li>
		<li class="col04">数量</li>
		<li class="col05">小计</li>
		<li class="col06">操作</li>
	</ul>

	<th:block th:each="cartVO:${list}">
		<ul th:id="${cartVO.id}" class="cart_list_td clearfix" >
			<li class="col01">
<!--				<input  th:if="${cartVO.checked==1}" type="checkbox" name="" checked>-->
				<input th:checked="${cartVO.checked}" type="checkbox" name="" th:onclick="|updateChecked(${cartVO.id}, this.checked)|">
			</li>
			<li class="col02"><img th:src="|/pic/${cartVO.productMainImage}|" height="100px" width="100px"></li>
			<li class="col03"><span th:text="${cartVO.productName}"></span><br><em th:text="|${cartVO.productPrice}元|"></em></li>
			<li class="col04">500g</li>
			<li class="col05" th:text="|${cartVO.productPrice}元|"></li>
			<li class="col06">
				<div class="num_add">
					<a href="javascript:;" class="add fl">+</a>
					<input type="text" class="num_show fl" th:value="${cartVO.quantity}">
					<a href="javascript:;" class="minus fl">-</a>
				</div>
			</li>
			<li class="col07" th:text="|${cartVO.productPrice}元|"></li>
			<li class="col08"><a th:onclick="|deleteById(${cartVO.id})|" href="javascript:;">删除</a></li>
		</ul>
	</th:block>
<!--	<ul class="cart_list_td clearfix" >-->
<!--		<li class="col01"><input type="checkbox" name="" checked></li>-->
<!--		<li class="col02"><img src="images/goods/goods003.jpg"></li>-->
<!--		<li class="col03">大兴大棚草莓<br><em>16.80元/500g</em></li>-->
<!--		<li class="col04">500g</li>-->
<!--		<li class="col05">16.80元</li>-->
<!--		<li class="col06">-->
<!--			<div class="num_add">-->
<!--				<a href="javascript:;" class="add fl">+</a>-->
<!--				<input type="text" class="num_show fl" value="1">	-->
<!--				<a href="javascript:;" class="minus fl">-</a>	-->
<!--			</div>-->
<!--		</li>-->
<!--		<li class="col07">16.80元</li>-->
<!--		<li class="col08"><a href="javascript:;">删除</a></li>-->
<!--	</ul>-->
	

	<ul class="settlements">
		<li class="col01"><input type="checkbox" name="" checked=""></li>
		<li class="col02">全选</li>
		<li class="col03">合计(不含运费)：<span>¥</span><em>42.60</em><br>共计<b>2</b>件商品</li>
		<li class="col04"><a href="/order/getOrderConfirmPage">去结算</a></li>
	</ul>

	<div class="footer">
		<div class="foot_link">
			<a href="#">关于我们</a>
			<span>|</span>
			<a href="#">联系我们</a>
			<span>|</span>
			<a href="#">招聘人才</a>
			<span>|</span>
			<a href="#">友情链接</a>		
		</div>
		<p>CopyRight © 2016 北京天天生鲜信息技术有限公司 All Rights Reserved</p>
		<p>电话：010-****888    京ICP备*******8号</p>
	</div>

	<script>
		function deleteById(id) {
			console.log(id);
			$.post(
				'/cart/deleteById',
				{'id' : id},
				function (result) {
					if (result.ok) {
						$('#'+id).remove();
						mylayer.okMsg(result.msg);
					}
				},
				'json'
			);
		}

		function updateChecked(id, checked) {
			console.log('cartId: ' + id);
			console.log('checked: ' + checked ? 1 : 0);
			$.post(
				'/cart/updateChecked',
				{'id' : id, 'checked' : checked ? 1 : 0},
				function (result) {
					if (result.ok) {
						mylayer.okMsg(result.msg);
					} else {
						mylayer.errorMsg(result.msg);
					}
				},
				'json'
			);
		}
	</script>
	
</body>
</html>